/**
 * ReportGear(2011)
 */
package com.reportgear.report.print.pane;

import java.awt.Dimension;
import java.awt.FlowLayout;

import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerNumberModel;

/**
 * 对话框-打印-单位字段面板
 * 
 * @version 1.0 2011-4-20
 * @author <a herf="lexloo@gmail.com">lexloo</a>
 * @since Report 1.0
 */
public class UnitFieldPane extends JPanel {
	private JSpinner valueSpinner;

	public UnitFieldPane() {
		this.setLayout(new FlowLayout(0, 3, 0));
		this.valueSpinner = new JSpinner(new SpinnerNumberModel(0.0D, 0.0D, Long.MAX_VALUE, 1.0D));
		JFormattedTextField formatField = ((JSpinner.DefaultEditor) this.valueSpinner.getEditor()).getTextField();
		formatField.setColumns(4);
		this.add(this.valueSpinner);
		JLabel lblUnit = new JLabel("毫米");

		Dimension dimUnit = new Dimension(lblUnit.getPreferredSize().width, this.valueSpinner.getPreferredSize().height);
		lblUnit.setMinimumSize(dimUnit);
		lblUnit.setMinimumSize(dimUnit);
		lblUnit.setSize(dimUnit);

		this.add(lblUnit);
	}

	public double getValue() {
		return ((Number) this.valueSpinner.getValue()).doubleValue();
	}

	public void setValue(double value) {
		this.valueSpinner.setValue(value);
	}
}